package com.fanyu.test.personal.controller;

import java.util.HashMap;
import java.util.Map;

import org.apache.commons.lang3.StringUtils;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.alibaba.fastjson2.JSON;
import com.fanyu.test.personal.CallbackVO;

import lombok.extern.slf4j.Slf4j;

@Slf4j
@RestController
@RequestMapping("/fanyuApiDemo")
public class CallbackController {

    @RequestMapping("/beginCallback")
    public String callBack(String paperguid, int state, String customparameter) {
        log.info("开始检测回传-------------------");
        log.info("paperguid---" + paperguid);
        log.info("state---" + state);
        log.info("customparameter---" + customparameter);
        Map<String, Object> param = new HashMap<>();
        if (StringUtils.isEmpty(paperguid) || StringUtils.isEmpty(customparameter)) {
            param.put("success", false);
        } else {
            param.put("success", true);
        }
        return JSON.toJSONString(param);
    }

    @RequestMapping("/finishCallback")
    public String finishCallback(CallbackVO callbackVO) {
        log.info("结束检测回传-------------------");
        log.info(callbackVO.toString());
        Map<String, Object> param = new HashMap<>();
        if (StringUtils.isEmpty(callbackVO.toString())) {
            param.put("success", false);
        } else {
            param.put("success", true);
        }
        return JSON.toJSONString(param);
    }
}
